<template>
  <div class="app-container" ref="appcontainer">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px">
      <el-row style="margin-bottom: 20px">
      <el-form-item label="订单号" prop="orderId">
        <el-input
          v-model="queryParams.combineOrder"
          placeholder="请输入订单号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
    </el-row>
      <el-row style="margin-bottom: 20px">
        <el-form-item label="退款状态" prop="refundStatus">
          <el-radio-group type="button" v-model="queryParams.refundStatus" @change="handleChange">
            <el-radio-button  label="">全部</el-radio-button>
            <el-radio-button label="no">未退款</el-radio-button>
            <el-radio-button label="apply">申请中</el-radio-button>
            <el-radio-button label="pass">商家通过</el-radio-button>
            <el-radio-button label="refunding">退款中</el-radio-button>
            <el-radio-button label="refused">拒绝退款</el-radio-button>
            <el-radio-button label="finished">退款完成</el-radio-button>

          </el-radio-group>
        </el-form-item>
      </el-row>
      <el-row style="margin-bottom: 20px">
        <el-form-item label="下单时间">
          <el-date-picker
            v-model="daterangeCreateTime"
            size="small"
            style="width: 240px"
            value-format="yyyy-MM-dd"
            type="daterange"
            range-separator="-"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
          ></el-date-picker>
        </el-form-item>
      </el-row>
      <el-form-item>
        <el-button type="primary"   size="mini" @click="handleQuery">搜索</el-button>
        <el-button   size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          size="mini"
          :loading="exportLoading"
          @click="handleExport"
          v-hasPermi="['shopping:mallOrder:export']"
          v-if="false"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :height="tableHeight" :data="mallOrderList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" show-overflow-tooltip />
      <el-table-column label="订单号" align="center" prop="combineOrder" />
      <el-table-column label="商品名称" align="center" prop="productName" />
      <el-table-column label="商品图片" align="center" prop="productImage">
        <template width="120" slot-scope="scope">
          <img style="width:60px;height:60px;border:none;" :src="scope.row.productImage">
        </template>
      </el-table-column>
      <el-table-column label="退款状态" align="center" prop="refundStatus">
        <template slot-scope="scope">
          <dict-tag :options="refundStatusOptions" :value="scope.row.refundStatus"/>
        </template>
      </el-table-column>
      <el-table-column label="实际支付金额" align="center" prop="payPrice" />
      <el-table-column label="下单时间" align="center" prop="createTime" />
      <el-table-column label="配送方式" align="center" prop="distributionDmode">
        <template slot-scope="scope">
          <dict-tag :options="distributionDmodeOptions" :value="scope.row.distributionDmode"/>
        </template>
      </el-table-column>
      <el-table-column label="退款原因" align="center" prop="refundReason">
        <!--<template slot-scope="scope">
          <dict-tag :options="refundReasonOptions" :value="scope.row.refundReason"/>
        </template>-->
      </el-table-column>
      <el-table-column label="退款时间" align="center" prop="refundTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.refundTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>

      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            @click="handleAtRefund(scope.row)"
            v-if="scope.row.refundStatus == 'apply'"
            v-hasPermi="['system:order:edit']"
          >立即退款</el-button>
          <el-button
            size="mini"
            type="text"
            @click="handleRefuseRefund(scope.row)"
            v-if="scope.row.refundStatus == 'apply'"
            v-hasPermi="['system:order:edit']"
          >拒绝退款</el-button>

          <el-dropdown size="mini" @command="(command) => handleCommand(command, scope.row)">
                <span class="el-dropdown-link">
                 更多<i class="el-icon-d-arrow-right el-icon--right"></i>
                </span>

            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item command="changeOrderDetails"  >订单详情</el-dropdown-item>
              <el-dropdown-item command="changeOrderRemark" >订单备注</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>


        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改商城订单对话框 -->
    <el-dialog :close-on-click-modal="false" :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="订单号" prop="orderId">
          <el-input v-model="form.orderId" placeholder="请输入订单号" />
        </el-form-item>
        <el-form-item label="合并订单号" prop="mergeOrderId">
          <el-input v-model="form.mergeOrderId" placeholder="请输入合并订单号" />
        </el-form-item>
        <el-form-item label="商品id" prop="productId">
          <el-input v-model="form.productId" placeholder="请输入商品id" />
        </el-form-item>
        <el-form-item label="商品名称" prop="productName">
          <el-input v-model="form.productName" placeholder="请输入商品名称" />
        </el-form-item>
        <el-form-item label="商品图片">
          <imageUpload v-model="form.productImage"/>
        </el-form-item>
        <el-form-item label="优惠券id" prop="couponId">
          <el-input v-model="form.couponId" placeholder="请输入优惠券id" />
        </el-form-item>
        <el-form-item label="快照id" prop="productBackId">
          <el-input v-model="form.productBackId" placeholder="请输入快照id" />
        </el-form-item>
        <el-form-item label="下单人id" prop="memberId">
          <el-input v-model="form.memberId" placeholder="请输入下单人id" />
        </el-form-item>
        <el-form-item label="实际支付金额" prop="payPrice">
          <el-input v-model="form.payPrice" placeholder="请输入实际支付金额" />
        </el-form-item>
        <el-form-item label="抵扣金额" prop="deductionPrice">
          <el-input v-model="form.deductionPrice" placeholder="请输入抵扣金额" />
        </el-form-item>
        <el-form-item label="订单状态" prop="orderState">
          <el-select v-model="form.orderState" placeholder="请选择订单状态">
            <el-option
              v-for="dict in orderStateOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="退款状态" prop="refundStatus">
          <el-select v-model="form.refundStatus" placeholder="请选择退款状态">
            <el-option
              v-for="dict in refundStatusOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="退款订单号" prop="refundPayOrderNo">
          <el-input v-model="form.refundPayOrderNo" placeholder="请输入退款订单号" />
        </el-form-item>
        <el-form-item label="退款支付状态" prop="refundPayStatus">
          <el-select v-model="form.refundPayStatus" placeholder="请选择退款支付状态">
            <el-option
              v-for="dict in refundPayStatusOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="退款支付失败原因" prop="refundPayErrMsg">
          <el-input v-model="form.refundPayErrMsg" placeholder="请输入退款支付失败原因" />
        </el-form-item>
        <el-form-item label="退款原因" prop="refundReason">
          <el-select v-model="form.refundReason" placeholder="请选择退款原因">
            <el-option
              v-for="dict in refundReasonOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="退款申请时间" prop="refundTime">
          <el-date-picker clearable size="small"
                          v-model="form.refundTime"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="选择退款申请时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="拒绝退款原因" prop="refundRefuseReaso">
          <el-input v-model="form.refundRefuseReaso" placeholder="请输入拒绝退款原因" />
        </el-form-item>
        <el-form-item label="平台金额" prop="platformMoney">
          <el-input v-model="form.platformMoney" placeholder="请输入平台金额" />
        </el-form-item>
        <el-form-item label="收货人姓名" prop="consigneeName">
          <el-input v-model="form.consigneeName" placeholder="请输入收货人姓名" />
        </el-form-item>
        <el-form-item label="商家金额" prop="storeMoney">
          <el-input v-model="form.storeMoney" placeholder="请输入商家金额" />
        </el-form-item>
        <el-form-item label="收货人地址" prop="consigneeAddress">
          <el-input v-model="form.consigneeAddress" placeholder="请输入收货人地址" />
        </el-form-item>
        <el-form-item label="退款金额" prop="refundMoney">
          <el-input v-model="form.refundMoney" placeholder="请输入退款金额" />
        </el-form-item>
        <el-form-item label="规格id" prop="specificationId">
          <el-input v-model="form.specificationId" placeholder="请输入规格id" />
        </el-form-item>
        <el-form-item label="配送方式" prop="distributionDmode">
          <el-select v-model="form.distributionDmode" placeholder="请选择配送方式">
            <el-option
              v-for="dict in distributionDmodeOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="是否已评价" prop="commentStatus">
          <el-select v-model="form.commentStatus" placeholder="请选择是否已评价">
            <el-option
              v-for="dict in commentStatusOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="收货人手机号" prop="consigneePhone">
          <el-input v-model="form.consigneePhone" placeholder="请输入收货人手机号" />
        </el-form-item>
        <el-form-item label="规格名称" prop="specificationName">
          <el-input v-model="form.specificationName" placeholder="请输入规格名称" />
        </el-form-item>
        <el-form-item label="门店id" prop="storeId">
          <el-input v-model="form.storeId" placeholder="请输入门店id" />
        </el-form-item>
        <el-form-item label="数量" prop="num">
          <el-input v-model="form.num" placeholder="请输入数量" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <!--    订单详情-->
    <el-dialog :close-on-click-modal="false" :title="titleDetails" :visible.sync="openDetails" width="700px" append-to-body>

      <el-form :model="addrInfo"  label-width="100px" >
        <div class="contentView">
          <el-form-item label="收货信息" />
          <el-row>
            <el-col :span="12">
              <el-form-item label="收货人：" >
                {{addrInfo.name}}
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="收货电话：" >
                {{addrInfo.phone}}
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item label="收货地址：" >
                {{addrInfo.address}}
              </el-form-item>
            </el-col>
          </el-row>
        </div>
      </el-form>

      <el-form label-width="100px" >
        <div class="contentView">
          <el-form-item label="商品信息" />
          <div class="levelOne">
            <div class="lineVine">
              <el-image class="proImg" :src="orderInfo.productImage"/>
              <div class="floatLeftView rightContentText">
                {{orderInfo.productName}} | {{orderInfo.specificationName}} {{orderInfo.totalPrice}} × {{orderInfo.num}}
              </div>
              <div class="cleanView"></div>
            </div>
            <div class="lineVine" v-if="orderInfo.distributionDmode == 'N'">
              <div class="floatLeftView blockView"> 快递方式：{{orderInfo.courierCompany}}</div>
              <div class="floatLeftView blockView"> 快递单号：{{orderInfo.courierNumber}}</div>
              <div class="floatLeftView blockView">发货时间：{{orderInfo.courierTime}}</div>
            </div>
            <div class="cleanView"></div>
          </div>
        </div>
      </el-form>
      <div class="contentView">
        <el-form :model="mesh"  label-width="100px" >
          <el-form-item label="订单信息" />
          <div class="none_border">
            <el-row>
              <el-col :span="12">
                <el-form-item label="订单号：" >
                  {{mesh.orderId}}
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="订单状态：" >
                  {{mesh.orderState}}
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="实际支付：" >
                  {{mesh.payPrice}}
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="下单时间：" >
                  {{mesh.createTime}}
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="支付方式：" >
                  微信支付
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="支付时间：" >
                  {{mesh.payTime}}
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="退款金额：" >
                  {{mesh.refundPrice}}
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="申请时间：" >
                  {{mesh.refundTime}}
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="退款原因：" >
                  {{mesh.refundReason}}
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="拒绝原因：" >
                  {{mesh.refundRefuse}}
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="退款状态：" >
                  {{mesh.refundStatus}}
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="买家备注：" >
                  {{mesh.buyerComment}}
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="商家备注：" >
                  {{mesh.saleComment}}
                </el-form-item>
              </el-col>
            </el-row>
          </div>
        </el-form>
      </div>

      <div slot="footer" class="dialog-footer">
        <el-button @click="cancel2">关闭</el-button>
      </div>
    </el-dialog>
    <el-dialog :close-on-click-modal="false" :title="titlePlatformRemark " :visible.sync="openPlatformRemark" width="700px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="平台备注" prop="platformRemark">
          <el-input v-model="form.platformRemark" type="textarea" placeholder="请输入内容" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="submitDelivery">确认</el-button>
        <el-button @click="cancel4">取消</el-button>
      </div>
    </el-dialog>
    <el-dialog :close-on-click-modal="false" :title="titleRefund" :visible.sync="openRefundDetails" width="700px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="拒绝退款原因" prop="refundRefuseReaso">
          <el-input v-model="form.refundRefuseReaso" placeholder="请输入拒绝退款原因" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="submitRefundDelivery">确认</el-button>
        <el-button @click="cancelRefund">取消</el-button>
      </div>
    </el-dialog>

  </div>
</template>

<script>
  import {updateRemark,editOrder,listMallAfterSaleOrder, getMallOrder, logicDelMallOrder, addMallOrder, updateMallOrder, exportMallOrder,queryAfterOrderDetail } from "@/api/shopping/mallOrder";
  import { getMallOrderMesh,} from "@/api/shopping/mallOrderMesh";
  import {getMember} from "@/api/member/member";
  export default {
    name: "MallOrder",
    data() {
      return {
        //拒绝退款获得到的id
        refundId:"",
        //输入的退款原因
        refundRefuseReaso:"",
        // 创建时间时间范围
        daterangeCreateTime: [],
        color:'#FFDAB9',
        //点击发送货选中的id
        tempId :"",
        //下单人信息
        userInfo:{},
        // 发货类型字典
        deliverytypeOptions: [],
        //合并订单信息
        mallOrderValue:{
          orderId:null,
          name:null,
          gainIntegral:null,
          useIntegral :null,
          payState:null,
          payOrderNo :null,
          payTime :null,
          payType:null,
        },
        tableHeight:0,
        // 遮罩层
        loading: true,
        // 导出遮罩层
        exportLoading: false,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: false,
        // 总条数
        total: 0,
        // 商城订单表格数据
        mallOrderList: [],
        // 弹出层标题
        title: "",
        //订单详情弹窗标题
        titleDetails:"",
        //发送货弹出标题
        titleDelivery:"",
        //平台备注标题
        titlePlatformRemark:"",
        //退款原因弹出层
        titleRefund:"",
        // 是否显示弹出层
        open: false,
        //订单详情弹出层
        openDetails:false,
        //发送货详情弹出层
        openDelivery:false,
        //平台备注弹出层
        openPlatformRemark:false,
        //退款原因弹出层
        openRefundDetails:false,
        // 快递公司字典
        courierCompanyOptions: [],
        // 订单状态字典
        orderStateOptions: [],
        // 退款状态字典
        refundStatusOptions: [],
        // 退款支付状态字典
        refundPayStatusOptions: [],
        // 退款原因字典
        refundReasonOptions: [],
        // 配送方式字典
        distributionDmodeOptions: [],
        // 是否已评价字典
        commentStatusOptions: [],
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          orderId: null,
          combineOrder:null,
          mergeOrderId: null,
          couponId:null,
          productId: null,
          productName: null,
          productImage: null,
          productBackId: null,
          memberId: null,
          payPrice: null,
          deductionPrice: null,
          orderState: null,
          platformRemark :null,
          courierCompany :null,
          refundStatus: null,
          createTime :null,
          refundPayOrderNo: null,
          refundPayStatus: null,
          refundPayErrMsg: null,
          deliverytype:null,
          refundReason: null,
          refundTime: null,
          refundRefuseReaso: null,
          platformMoney: null,
          consigneeName: null,
          storeMoney: null,
          consigneeAddress: null,
          refundMoney: null,
          specificationId: null,
          distributionDmode: null,
          commentStatus: null,
          consigneePhone: null,
          courierNumber: null,
          specificationName: null,
          storeId: null,
          num: null,
        },
        // 表单参数
        form: {},
        // 表单校验
        rules: {
        },
        mesh:{},
        addrInfo:{},
        orderInfo:{}
      };
    },
    beforeRouteEnter(to, form, next) {
      next(vm => {
        const refundStatus = vm.$route.query && vm.$route.query.refundStatus;
        console.log(refundStatus)
        if(refundStatus){
          vm.queryParams.refundStatus = refundStatus;
          vm.getList();
        }
      });
    },
    created() {
      this.getList();
      this.calHeight()
      this.getDicts("delivery_type").then(response => {
        this.deliverytypeOptions = response.data;
      });
      this.getDicts("order_state").then(response => {
        this.orderStateOptions = response.data;
      });
      this.getDicts("refund_status").then(response => {
        this.refundStatusOptions = response.data;
      });
      this.getDicts("logistics_company").then(response => {
        this.courierCompanyOptions = response.data;
      });
      this.getDicts("sys_yes_no").then(response => {
        this.refundPayStatusOptions = response.data;
      });
      this.getDicts("refund_cause").then(response => {
        this.refundReasonOptions = response.data;
      });
      this.getDicts("sys_distribution_dmode").then(response => {
        this.distributionDmodeOptions = response.data;
      });
      this.getDicts("sys_yes_no").then(response => {
        this.commentStatusOptions = response.data;
      });
    },
    watch: {
      'showSearch':'calHeight'
    },
    methods: {

    //立即退款
      handleAtRefund(row){
        this.$confirm('是否立即退款?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(() => {
          let query= {
            id : row.id,
            status: "pass",
          }
          editOrder(query).then(response => {
            this.msgSuccess("立即退款成功");
            this.openRefundDetails = false;
            this.getList();
          });
        }).then(response => {
        }).catch(() => {});
      },
      //拒绝退款取消按钮
      cancelRefund(){
        this.openRefundDetails = false;
        this.reset();
      },
      //拒绝退款按钮
      handleRefuseRefund(row) {
         this.refundId= row.id
        getMallOrder(row.id).then(response => {
          this.form = response.data;
          this.openRefundDetails = true;
          this.titleRefund = "拒绝退款";
        });
       },
//拒绝退款
      submitRefundDelivery (row){
        let query= {
          id : this.refundId,
          status: "refused",
          refundReason:this.form.refundRefuseReaso,
        }
        editOrder(query).then(response => {
          this.msgSuccess("已拒绝退款");
          this.getList();
          this.openRefundDetails = false;
        });
      },
      //平台备注
      submitDelivery(){
        let form=this.form;
        let query={
          id: form.id,
          remark: form.platformRemark
        }
        updateRemark(query).then(response => {
          this.msgSuccess("备注成功");
          this.openDelivery = false;
          this.openPlatformRemark= false;
          this.getList();
        });
      },
      //发送货按钮
      handeDelivery(row){
        this.reset();
        const id = row.id || this.ids
        getMallOrder(id).then(response => {
          this.form = response.data;
          this.openDelivery=true;
          this.titleDelivery = "发送货";
        });
        this.tempId = row.id
      },
      //查询订单状态
      handleChange(val){
        this.queryParams.refundStatus = val;
        this.getList();
      },
      //更多操作
      handleCommand(command, row){
        switch (command) {
          case "changeOrderDetails":
            this.changeOrderDetails(row);
            break;
          case "changeOrderRemark":
            this.changeOrderRemark(row);
            break;
          default:
            break;
        }
      },
      //订单详情
      changeOrderDetails(row){
    console.log(row)
        this.openDetails = true;
        this.titleDetails = "订单详情";
        // this.query.mergeOrderId=row.id
        queryAfterOrderDetail(row.id).then(res=>{
          this.mesh = res.data.mesh
          this.addrInfo = res.data.addr
          this.orderInfo = res.data.order
        })
      },
      //订单备注
      changeOrderRemark(row){
        this.reset();
        const id = row.id || this.ids
        getMallOrder(id).then(response => {
          this.form = response.data;
          this.openPlatformRemark = true;
          this.titlePlatformRemark = "平台备注"
        });
        this.tempId = row.id
      },
      calHeight () {
        this.$nextTick(() => {
          const rect = this.$refs.appcontainer.getBoundingClientRect();
          let height= this.$refs.queryForm.$el.offsetHeight;
          this.tableHeight = rect.height-height-120;
        })
      },
      /** 查询商城售后订单列表 */
      getList() {
        this.loading = true;
        this.queryParams.params = {};
        if (null != this.daterangeCreateTime && '' != this.daterangeCreateTime) {
          this.queryParams.params["beginCreateTime"] = this.daterangeCreateTime[0];
          this.queryParams.params["endCreateTime"] = this.daterangeCreateTime[1];
        }
        listMallAfterSaleOrder(this.queryParams).then(response => {
          this.mallOrderList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
      cancel2(){
        this.openDetails = false;
        this.reset();
      },
      cancel3(){
        this.openDelivery = false;
        this.reset();
      },
      cancel4(){
        this.openPlatformRemark = false;
        this.reset();
      },
      // 表单重置
      reset() {
        this.form = {
          id: null,
          orderId: null,
          combineOrder:null,
          mergeOrderId: null,
          deliverytype:null,
          productId: null,
          productName: null,
          productImage: null,
          productBackId: null,
          memberId: null,
          payPrice: null,
          deductionPrice: null,
          orderState: null,
          refundStatus: null,
          refundPayOrderNo: null,
          refundPayStatus: null,
          refundPayErrMsg: null,
          refundReason: null,
          platformRemark :null,
          courierCompany:null,
          refundTime: null,
          refundRefuseReaso: null,
          platformMoney: null,
          consigneeName: null,
          storeMoney: null,
          consigneeAddress: null,
          refundMoney: null,
          specificationId: null,
          distributionDmode: null,
          commentStatus: null,
          consigneePhone: null,
          delState: null,
          delUser: null,
          courierNumber: null,
          delType: null,
          delTime: null,
          specificationName: null,
          createBy: null,
          storeId: null,
          createType: null,
          num: null,
          createTime: null,
          updateBy: null,
          updateType: null,
          updateTime: null
        };
        this.resetForm("form");
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.showSearch=false;
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.queryParams.refundStatus = null;
        this.daterangeCreateTime = null;
        this.resetForm("queryForm");
        this.handleQuery();
      },
      // 多选框选中数据
      handleSelectionChange(selection) {
        this.ids = selection.map(item => item.id)
        this.single = selection.length!==1
        this.multiple = !selection.length
      },
      /** 新增按钮操作 */
      handleAdd() {
        this.reset();
        this.open = true;
        this.title = "添加商城订单";
      },
      /** 提交按钮 */
      submitForm() {
        this.$refs["form"].validate(valid => {
          if (valid) {
            if (this.form.id != null) {
              updateMallOrder(this.form).then(response => {
                this.msgSuccess("修改成功");
                this.open = false;
                this.getList();
              });
            } else {
              addMallOrder(this.form).then(response => {
                this.msgSuccess("新增成功");
                this.open = false;
                this.getList();
              });
            }
          }
        });
      },
      /** 删除按钮操作 */
      handleDelete(row) {
        const ids = row.id || this.ids;
        this.$confirm('是否确认删除?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return logicDelMallOrder(ids);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        }).catch(() => {});
      },
      /** 导出按钮操作 */
      handleExport() {
        const queryParams = this.queryParams;
        this.$confirm('是否确认导出所有商城订单数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(() => {
          this.exportLoading = true;
          return exportMallOrder(queryParams);
        }).then(response => {
          this.download(response.msg);
          this.exportLoading = false;
        }).catch(() => {});
      }
    }
  };
</script>
<style scoped>
.el-form-item {
  margin-bottom: 0px !important;
}
.contentView{
  width: 96%;
  /*padding: 0 20px 0 0;*/
  margin-bottom: 20px;
  margin-left: 18px;
  border: 1px solid #dcdfe6;
  border-radius: 10px;
}
.levelOne{
  padding: 4px 10px;
  box-sizing: border-box;
}
.levelOne .proImg{
  height: 50px;
  width: 50px;
  float: left;
  border-radius: 4px;
}
.levelOne .floatLeftView{
  float: left;
}
.levelOne .rightContentText{
  width: 530px;
  line-height: 25px;
  padding: 0 10px;
  box-sizing: border-box;
}
.levelOne .lineVine{
  padding: 2px 0;
}
.rightBtn{
  height: 26px;
  line-height: 26px;
  border: 1px solid #ccc;
  padding: 0 5px;
  box-sizing: border-box;
  font-size: 12px;
  border-radius: 4px;
  margin-top: 10px;
}
.cleanView{
  clear: both;
}
.levelOne .blockView{
  line-height: 35px;
  font-size: 14px;
  padding: 0 5px;
  margin-right: 10px;
}
</style>
